﻿@using ZBJF.Warranty.BLL
@model List<ZBJF.Warranty.Model.RoleToSystemUser>
@{
    using (Html.BeginForm("SaveRoleToSystemUserMapping", "Admin", FormMethod.Post, new { id = "mvcForm", name = "mvcForm", @class = "form-horizontal", enctype = "multipart/form-data" }))
    {
        long systemUserID = 0;
        if (!long.TryParse(Request["UserID"], out systemUserID))
        {
            <text>没有找到该用户信息</text>;
            return;
        }
        var employee = ServiceFactory.SystemUserServiceInstance.Load(systemUserID);
        var systemRoles = ServiceFactory.SystemRoleServiceInstance.LoadEntities(o => true);
        var roleIds = Model.Select(o => o.RoleID).ToList();
        @Html.Hidden("UserID", systemUserID);
    <div class="control-group">
        <label class="control-label w-100">用户名:</label>
        <div class="controls margin-l-120">
            <label class="padding-t-0">
                @employee.UserDisPlayName
            </label>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label w-100">用户账号:</label>
        <div class="controls margin-l-120">
            <label class="padding-t-0">
                @employee.UserAccount
            </label>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label w-100">角色:</label>
        <div class="controls margin-l-120">
            @{
                                            var count = 1;
                                            foreach (var item in systemRoles)
                                            {
                                                <label class="padding-l-5 w-120">
                                                    <input name="RoleID" @(roleIds.Contains(item.ID) ? "checked=checked" : "") type="checkbox" value="@item.ID" />
                                                    @item.RoleName
                                                </label>
                                                if (count % 4 == 0)//一行显示n个
                                                {
                                                    <br />
                                                }
                                                count++;
                                            }
            }
        </div>
    </div>
    <div class="align-center">
        <input id="btnSubmit" class="btn btn-primary Edit-R" type="submit" value="提交">
        <input id="btnCancel" class="btn" type="button" value="取消" onclick="parent.layer.closeAll()">
    </div>
    }
}